// pages/mine/mine.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url:'',
    class_icon:[],//分类小图标数据
    banner_img:[],//轮播
    chang:[],//畅销
    icon_url:"https://rt.gzziyu.com/mobile/",
    lunbo_url:"https://rt.gzziyu.com/mobile/data/afficheimg/",
    pro_url:'https://rt.gzziyu.com/',
    guanggao:'https://rt.gzziyu.com/mobile/data/afficheimg/',
    dan_img1: [],
    dan_img2: [],
    dan_img3: [],
    dan_img4: [],
    dan_img5:[],
    
  },
  go_list:function(){
    console.log(123)
    wx.navigateTo({
      url: '../list/list'
    });
  } ,
  go_good:function(e){
    wx.navigateTo({
      url: '../list/detail/detail?id='+e.currentTarget.dataset.url
    })
  },
  
  tocomdetail(e) {
    console.log(e.currentTarget.id)
    wx.navigateTo({
      url: '../list/detail/detail?id=' + e.currentTarget.id
    })
  },
  search:function(){
    wx.navigateTo({
      url: '../search/search'
    });
  },
  // 畅销推荐
  changxiao: function (e) {
    var that = this;
    wx.request({
      url: 'https://rt.gzziyu.com/mobile/ziyu.php?Action=hotproduct',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        console.log(res);
        // var arr = [];
        // var data = res.data;
        // for (var i in data) {
        //   arr.push(data[i]);
        // }
        that.setData({
          chang: res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    // 轮播图
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=touch_ad',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({
          banner_img:res.data
        })
        console.log(res.data)
      }
    })
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=danzhang&shuzi=9',
      success:function(res){
        console.log(res)
        that.data.dan_img1.push(res.data)
        that.setData({
          dan_img1:that.data.dan_img1
        })
        console.log(that.data.dan_img1[0][0])
      }
      
    })
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=danzhang&shuzi=8',
      success: function (res) {
        console.log(res)
        that.data.dan_img2.push(res.data)
        that.setData({
          dan_img2: that.data.dan_img2
        })
        console.log(that.data.dan_img2[0][0])
      }

    })
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=danzhang&shuzi=11',
      success: function (res) {
        console.log(res)
        that.data.dan_img3.push(res.data)
        that.setData({
          dan_img3: that.data.dan_img3
        })
        console.log(that.data.dan_img3[0][0])
      }

    })
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=danzhang&shuzi=6',
      success: function (res) {
        console.log(res)
        that.data.dan_img4.push(res.data)
        that.setData({
          dan_img4: that.data.dan_img4
        })
        console.log(that.data.dan_img4[0][0])
      }

    })
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=danzhang&shuzi=10',
      success: function (res) {
        console.log(res)
        that.data.dan_img5.push(res.data)
        that.setData({
          dan_img5: that.data.dan_img5
        })
        console.log(that.data.dan_img5[0][0])
      }

    })

    // 分类图标
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=ctype',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success:function(res){
        console.log(res)
        that.setData({
          url:app.globalData.url,
          class_icon: res.data
        })
      }
    })
    that.changxiao();

  },
  
  geturl:function(e){
    console.log(e.target.dataset.url)
    app.globalData.listname = e.target.dataset.url ;
    wx.switchTab({
      url: '../list/list'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})